﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ECRMS.WinForm.WinService;

namespace ECRMS.WinForm.BaseClass.Common
{
    //此类用于指标分配
    public class IndexOfPlan
    {
        public List<CtIndexGroup> IndexGroups;
        public List<CtIndex> OperatorRowIndexs;

        //得到指标分组列表
        public FuncResult GetIndexGroups(Guid corpId,int userTypeId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtIndexGroupOUJwPUXg result = ser.CtGetIndexGroups(corpId,userTypeId);
                if (result.Status == 1)
                {
                    this.IndexGroups = result.Data;
                }
                return new FuncResult
                {
                    Status = result.Status,
                    Message = result.Message
                };
            }
        }

        //得到某个指标分组下面的所有指标
        public FuncResult GetIndexs(Guid groupId)
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtIndexOUJwPUXg result = ser.CtGetIndexsByGroupId(groupId);
                if (result.Status == 1)
                {
                    this.OperatorRowIndexs = result.Data;
                }
                return new FuncResult
                {
                    Status = result.Status,
                    Message = result.Message
                };
            }
        }

        //更新指标分配后的指标
        public FuncResult UpdateIndexs()
        {
            using (var ser = new ECRServiceClient())
            {
                CtServiceResultOfArrayOfCtIndexOUJwPUXg result = ser.CtUpdateIndexs(OperatorRowIndexs);
                if (result.Status == 1)
                {
                    OperatorRowIndexs = result.Data;
                }
                return new FuncResult
                {
                    Status = result.Status,
                    Message = result.Message
                };
            }
        }


    }
}
